Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append AZURE_HTTP_USER_AGENT environment variable to UserAgent string. #483

Merged
merged 3 commits into from
Nov 4, 2017
Merged

Conversation

WodansSon
Copy link
Collaborator

No description provided.

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @jeffreyCline

Thanks for this PR :)

I've taken a look and it mostly LGTM (I've left a couple of minor comments around our conventions going forward - but they're not blockers by any means). Out of interest, where's this environment variable going to be set?

Thanks!

@@ -189,7 +191,15 @@ func withRequestLogging() autorest.SendDecorator {

func setUserAgent(client *autorest.Client) {
version := terraform.VersionString()
azureAgent := os.Getenv("AZURE_HTTP_USER_AGENT")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of interest - what's the use-case for this / where's this going to be set?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The azure compute cloud shell sets this in their dockerfile (i.e. ENV AZURE_HTTP_USER_AGENT cloud-shell/1.0). This way we can collect some BI data on the provider/environment usage.


if azureAgent != "" {
s := []string{client.UserAgent, azureAgent}
client.UserAgent = strings.Join(s, ";")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor we'd tend to just format this directly:

client.UserAgent = fmt.Sprintf("%s;%s", client.UserAgent, azureAgent)

client.UserAgent = fmt.Sprintf("HashiCorp-Terraform-v%s", version)

if azureAgent != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor we'd tend to make this:

if azureAgent := os.Getenv("AZURE_HTTP_USER_AGENT"); azureAgent != "" {
 // set it
}

rather than separating it out :)

@@ -190,6 +191,12 @@ func withRequestLogging() autorest.SendDecorator {
func setUserAgent(client *autorest.Client) {
version := terraform.VersionString()
client.UserAgent = fmt.Sprintf("HashiCorp-Terraform-v%s", version)

if azureAgent := os.Getenv("AZURE_HTTP_USER_AGENT"); azureAgent != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to add a comment here to explain it ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pushed a commit to add this.

@metacpp
Copy link
Contributor

metacpp commented Nov 3, 2017

@tombuildsstuff after it's merged, when it will be released to public ? We want to let the BI team start the monitoring after the release.

@tombuildsstuff
Copy link
Contributor

Confirmed this matches the environment variable within CloudShell:
screen shot 2017-11-04 at 08 59 39

@tombuildsstuff
Copy link
Contributor

@metacpp I'm not sure exactly when - but we'll do a release at some point early next week :)

@tombuildsstuff tombuildsstuff merged commit d6f95ed into hashicorp:master Nov 4, 2017
tombuildsstuff added a commit that referenced this pull request Nov 4, 2017
@metacpp
Copy link
Contributor

metacpp commented Nov 6, 2017

@tombuildsstuff thanks for the quick merge. @jeffreyCline will follow up on the release of plugin.

@ghost
Copy link

ghost commented Apr 1, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants